package com.hr.util;

import com.hr.model.DepartmentModel;
import com.hr.model.UserModel;
import com.hr.service.DepartmentService;
import com.hr.service.UserService;

public class MyTag {
	/**
	 * 将员工ID转换为员工姓名
	 * @param user_id
	 * @return
	 */
	public static  String getUserName(String user_id){
		UserService userService  = (UserService) SpringContextUtil.getBean("userServiceImpl");//bean的名称 
		UserModel user = userService.findByPrimaryKey(user_id);
		if(user==null)
			return null;
		else
		return user.getName();
	}
	/**
	 * 根据部门编号获取部门名称
	 * @param code
	 * @return
	 */
	public static String getDepartment(String code){
		DepartmentService departmentService  = (DepartmentService) SpringContextUtil.getBean("departmentServiceImpl");//bean的名称 
		DepartmentModel department = departmentService.findByPrimaryKey(code);
		if(department!=null)
			return department.getName();
		return null;
	}
}

